package com.free.coder.javaplus.views;

import java.io.File;

import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.ui.part.*;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.viewers.*;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.jface.action.*;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.*;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.SWT;

import com.free.javadodo.swt.ui.ViewDs;
import com.opnworks.tableviewer.example.TableViewerExample;
 

/**
 * This sample class demonstrates how to plug-in a new workbench view. The view
 * shows data obtained from the model. The sample creates a dummy model on the
 * fly, but a real implementation would connect to the model available either in
 * this or another plug-in (e.g. the workspace). The view is connected to the
 * model using a content provider.
 * <p>
 * The view uses a label provider to define how model objects should be
 * presented in the view. Each view can present the same model objects using
 * different labels and icons, if needed. Alternatively, a single label provider
 * can be shared between views in order to ensure that objects of the same type
 * are presented in the same way everywhere.
 * <p>
 */

public class JavaPlus extends ViewPart {
	private Button button = null;
	private Tree tree = null;
	private TreeViewer treeViewer = null;
	Point p = null;
	static String path = configPath();
	Composite sShell = null;
	/**
	 * The constructor.
	 */
	public JavaPlus() {
		
	}

	/**
	 * This is a callback that will allow us to create the viewer and initialize
	 * it.
	 */
	 
	public void createPartControl(Composite parent) {
		sShell = parent;// .getShell();
		ViewDs viewds = new ViewDs(sShell); 
		viewds.createSShell();
	}
 /*
	//-------------------------------
	private TableViewerExample viewer;
	public void createPartControl(Composite parent) {
		viewer = new TableViewerExample(parent);
		viewer.getCloseButton().addSelectionListener(new SelectionAdapter() {
       	
			// Close the view i.e. dispose of the composite's parent
			public void widgetSelected(SelectionEvent e) {
				handleDispose();
			}
		});
	}
	*/
	public void handleDispose() {	
		this.getSite().getPage().hideView(this);
	}
	//-------------------------------
	
	/**
	 * Passing the focus request to the viewer's control.
	 */
	public void setFocus() {
		// viewer.getControl().setFocus();
	}
	
	public static String configPath() {
		String path = "";
		try {
			path = Platform.asLocalURL(
					Platform.getConfigurationLocation().getURL()).getFile();
			path = path.concat("eos_studio_config").concat(File.separator);
			File file = new File(path);
			if (!file.exists())
				file.mkdirs();
		} catch (Exception e) {
		}
		return path;
	}
}